package org.neogenesis.web.loader;

import org.neogenesis.web.model.Gene;

public class MetaProbe {

	private String probeId = "";
	private String geneId = "";
	private String geneSymbol = "";

	private Gene gene;

	/**
	 * used from import platform DAO
	 * 
	 * @param row
	 * @param geneColumn
	 * @param typeMetaPlatform
	 */
	public MetaProbe(String[] row, int geneColumn,
			TypeMetaPlatform typeMetaPlatform) {

		probeId = row[0];

		String tmp = row[geneColumn];
		String[] split;

		switch (typeMetaPlatform) {
		case ENTREZ_GENE_ID:
			geneId = tmp;
			break;
		case GENE_ID:
			split = tmp.split(":");
			geneId = split[1];
			break;

		case GENE_ASSIGNMENT:
			// splitto il campo geneAssistement per ricavare i diversi
			// gene_assignment
			String[] splitGeneAssignment = tmp.split(" /// ");

			// ho ricavato il primo geneAssignment e lo splitto
			String firstGeneAssignment = splitGeneAssignment[0];

			String[] geneInfos = firstGeneAssignment.split(" // ");
			geneId = geneInfos[4];
			geneSymbol = geneInfos[1];
			break;
		case GENE_SYMBOL:
			geneSymbol = tmp.trim();
			break;
		case GENE:
			geneId = tmp;
			break;
		case LOCUS:
			geneId = tmp;
			break;
		default:
			break;
		}

		// safe check probably we can remove it
		split = geneId.split(" /// ");
		if (split.length > 0)
			geneId = split[0];

	}

	@Override
	public String toString() {
		return probeId + " " + geneSymbol + " " + geneId;
	}

	public String getProbeId() {
		return probeId;
	}

	public void setProbeId(String probeId) {
		this.probeId = probeId;
	}

	public String getGeneId() {
		return geneId;
	}

	public void setGeneId(String geneId) {
		this.geneId = geneId;
	}

	public String getGeneSymbol() {
		return geneSymbol;
	}

	public void setGeneSymbol(String geneSymbol) {
		this.geneSymbol = geneSymbol;
	}

	public Gene getGene() {
		return gene;
	}

	public void setGene(Gene gene) {
		this.gene = gene;
	}
}
